package com.fankui.servicestatistics.controller;


import com.fankui.commonutils.R;
import com.fankui.servicestatistics.service.StatisticsDailyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author 范奎
 * @since 2023-12-13
 */
@Api(description = "统计分析管理")
@RestController
@RequestMapping("/statisticsservice/statistics")
public class StatisticsDailyController {
    @Autowired
    private StatisticsDailyService statisticsDailyService;

    @ApiOperation(value = "统计某一天的注册人数")
    @PostMapping("registerCount/{day}")
    public R registerCount(@ApiParam(value = "day", name = "日期", required = true) @PathVariable String day) {
        statisticsDailyService.registerCount(day);
        return R.ok();
    }

    @ApiOperation(value = "获取图表展示数据")
    @GetMapping("getShowData/{type}/{begin}/{end}")
    public R getShowData(@ApiParam(value = "type", name = "统计因子", required = true) @PathVariable String type,
                         @ApiParam(value = "begin", name = "开始日期", required = true) @PathVariable String begin,
                         @ApiParam(value = "end", name = "结束日期", required = true) @PathVariable String end) {
        Map<String, Object> map = statisticsDailyService.getShowData(type, begin, end);
        return R.ok().data(map);
    }
}

